//
//  HLCustomContentConfig.m
//  YueYue
//
//  Created by hulu001 on 2023/6/12.
//

#import "HLCustomContentConfig.h"
#import "HLCustomAttachmentInfo.h"
#import <NIMSDK/NIMSDK.h>


@implementation HLCustomContentConfig


- (CGSize)contentSize:(CGFloat)cellWidth message:(NIMMessage *)message
{
    NIMCustomObject *object = (NIMCustomObject *)message.messageObject;
    NSAssert([object isKindOfClass:[NIMCustomObject class]], @"message must be custom");
    id<HLCustomAttachmentInfo> info = (id<HLCustomAttachmentInfo>)object.attachment;
    return [info contentSize:message cellWidth:cellWidth];
}

- (NSString *)cellContent:(NIMMessage *)message
{
    NIMCustomObject *object = (NIMCustomObject *)message.messageObject;
    NSAssert([object isKindOfClass:[NIMCustomObject class]], @"message must be custom");
    id<HLCustomAttachmentInfo> info = (id<HLCustomAttachmentInfo>)object.attachment;
    return [info cellContent:message];
}

- (UIEdgeInsets)cellInsets:(NIMMessage *)message
{
    NIMCustomObject *object = (NIMCustomObject *)message.messageObject;
    NSAssert([object isKindOfClass:[NIMCustomObject class]], @"message must be custom");
    id<HLCustomAttachmentInfo> info = (id<HLCustomAttachmentInfo>)object.attachment;
    return [info cellInsets:message];
}

- (UIEdgeInsets)contentViewInsets:(NIMMessage *)message
{
    NIMCustomObject *object = (NIMCustomObject *)message.messageObject;
    NSAssert([object isKindOfClass:[NIMCustomObject class]], @"message must be custom");
    id<HLCustomAttachmentInfo> info = (id<HLCustomAttachmentInfo>)object.attachment;
    return [info contentViewInsets:message];
}

- (BOOL)showAvatar:(NIMMessage *)message
{
    NIMCustomObject *object = (NIMCustomObject *)message.messageObject;
    NSAssert([object isKindOfClass:[NIMCustomObject class]], @"message must be custom");
    id<HLCustomAttachmentInfo> info = (id<HLCustomAttachmentInfo>)object.attachment;
    return [info shouldShowAvatar:message];
}


@end
